home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4298 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  62 lines

  1. Path: ionews.ionet.net!usenet
  2. From: David Shaffer <dshaffer@traffic.jam.net>
  3. Newsgroups: comp.lang.c
  4. Subject: printf changing a pointer
  5. Date: Fri, 02 Feb 1996 21:41:13 -0600
  6. Organization: Shaffer Systems
  7. Message-ID: <3112D959.58AD6E2A@traffic.jam.net>
  8. NNTP-Posting-Host: osip20.ionet.net
  9. Mime-Version: 1.0
  10. Content-Type: multipart/mixed;
  11.     boundary="---------------------------207030344915297696601643038769"
  12. X-Mailer: Mozilla 2.0b4 (X11; I; Linux 1.2.8 i486)
  13.  
  14. This is a multi-part message in MIME format.
  15.  
  16. -----------------------------207030344915297696601643038769
  17. Content-Type: text/plain; charset=us-ascii
  18. Content-Transfer-Encoding: 7bit
  19.  
  20. I don't understand the following...
  21.  
  22. -- 
  23. David Shaffer
  24. http://traffic.jam.net/~dshaffer
  25.  
  26. -----------------------------207030344915297696601643038769
  27. Content-Type: text/plain; charset=iso-8859-1
  28. Content-Transfer-Encoding: 8bit
  29. Content-Disposition: inline; filename="prog1.out"
  30.  
  31. *** this is the output
  32. initializing data base... prog1.bin to hash file hash.dat...
  33. initializing hash table entries... depth of this table is 0
  34. creating a bucket at file location 0...
  35. creating a bucket at file location 1200...
  36. creating a bucket at file location 2400...
  37. creating a bucket at file location 3600...
  38. creating a bucket at file location 4800...
  39. creating a bucket at file location 6000...
  40. creating a bucket at file location 7200...
  41.  
  42. *** this is what gdb shows
  43. 45        record = (RECORD*)get_entry (maintable,"WASH", hashfile, binaryfile);
  44. (gdb)
  45. 46        printf("%s\n",record->city);
  46. (gdb) print record
  47. $1 = (RECORD *) 0xbffffbc8
  48. (gdb) print *record
  49. $2 = {city = "WASH", date = "01/17", time = "1745", air_temp = 0,
  50.   wind_speed = 0, wind_direction = 0, rain_amount = 0}
  51. (gdb) s
  52.  
  53. 47      }
  54. (gdb) print *record
  55. $3 = {city = "\017\021\000", date = "\226\020\000\000ñ", time = "√ ┐5",
  56.   air_temp = 0, wind_speed = 0, wind_direction = 0, rain_amount = 0}
  57.  
  58. why is record changed by a printf statement?
  59.  
  60. -----------------------------207030344915297696601643038769--
  61.  
  62.